/**
 * create by young (young2f@outlook.com) on 2020/12/3
 */
'use strict';
const model = require('../base/modelBase');
const _ = require('lodash');
module.exports = app => {
    const mongoose = app.mongoose;
    const schema = mongoose.Schema;
    //schema.plugin(require('mongoose-timestamp'));
    // schema.set('timestamps', true);
    const connect = app.mongooseDB.get('aiotBusiness');
    const json = {
        timeStr: {type: String, desc: '时间'},
        timeSpace: {type: Number, desc: '统计时间间隔'},
        time: {type: Number, desc: '时间'},
        chiller: {type: Array, desc: '主机'},
        freezingPumpFreq: {type: Array, desc: '水泵'},
        freezingPumpFreqAvg: {type: Number, desc: '主机出水温度'},
        coolingPumpFreq: {type: Array, desc: '水泵'},
        coolingPumpFreqAvg: {type: Number, desc: '主机出水温度'},
        towerFreq: {type: Array, desc: '主机出水温度'},
        towerFreqAvg: {type: Number, desc: '主机出水温度'},
        chillerCapAvg: {type: Number, desc: '主机出水温度'},
        chillerRunCount: {type: Number, desc: '主机运行数量'},
        freezingOutTempSet: {type: Number, desc: '主机运行数量'},

        iceSys: {type: Object, desc: '系统'},
        temp: {type: Object, desc: '温度'},
        power: {type: Object, desc: '电能'},
        chillerPower: {type: Number, desc: '电能'},
        towerPower: {type: Number, desc: '电能'},
        coolingPumpPower: {type: Number, desc: '电能'},
        freezingPumpPower: {type: Number, desc: '电能'},

        freezingOutTempAvg: {type: Number, desc: '主机出水温度'},
        freezingOutTemp: {type: Array, desc: '主机出水温度'},
        avgEnvTemp: {type: Number, desc: '主机出水温度'},
        avgSetTemp: {type: Number, desc: '主机出水温度'},
        maxEnvTemp: {type: Number, desc: '主机出水温度'},
        cross25: {type: Number, desc: '超25.5'},
        outsideTemp: {type: Number, desc: '主机出水温度'},
        outsideHum: {type: Number, desc: '主机出水温度'},
        airRunCount: {type: Number, desc: '主机出水温度'},
        airCount: {type: Number, desc: '主机出水温度'},
    };
    const _model = _.cloneDeep(model);
    _.assign(_model, json);
    const _schema = new schema(
        _model
        //{ timestamps: { createdAt: 'createdTs', updatedAt: 'updatedTs' } }
    );
    return connect.model('Assess', _schema);
};
